/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ManejoMantenimientoGUI.java
 *
 * Created on Dec 20, 2011, 5:43:20 PM
 */
package Gui;

import Logica.CreacionInformacion;
import Logica.EdicionInformacion;
import Logica.EliminacionInformacion;
import Oracle.OracleMethods;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import kioscos.Pedido;

/**
 *
 * @author odmaestrams
 */
public class ManejoMantenimientoGUI extends javax.swing.JFrame {

    private SimpleDateFormat fecha = new SimpleDateFormat("dd/MM/yyyy");
    private SimpleDateFormat fecha2 = new SimpleDateFormat("yyyy-MM-dd");
    
    private Integer nroMantAnterior;
    private Integer nroKioscoAnterior;
    private String ciEmpleadoAnterior;
    private Integer horasTAnterior;
    private String fechaMantAnterior;
    private String tipoMantAnterior;
    private Integer montoMantAnterior;
    private String[] infoMant = null;
    private Integer montoTotalPedidos = 0;
    private ArrayList<Pedido> arrayPedidos = new ArrayList<Pedido>();
    
    /** Creates new form ManejoMantenimientoGUI */
    public ManejoMantenimientoGUI() {
        initComponents();
        this.setLocationRelativeTo(null);
    }
    
    public ManejoMantenimientoGUI(String opcion) throws SQLException{
        initComponents();
        this.setLocationRelativeTo(null);
        
        if (opcion.equals("M")){
            this.jPanel1.setBorder(BorderFactory.createTitledBorder("Manejo mantenimientos"));
            this.jLabel1.setText("Kiosco:");
            this.manejoMantenimiento_Pane.remove(infoPedido_Panel);
            this.manejoMantenimiento_Pane.remove(creacionPedido_Panel);
            infoBox.addItem("Kiosco - Nombre");
            infoBox.setSelectedItem("Kiosco - Nombre");
            this.manejoMantenimiento_Pane.setEnabledAt(1, false);
            this.panelManejoMantenimiento.setVisible(true);
            this.panelManejoPedido.setVisible(false);
            this.jLabel22.setVisible(false);
            this.jLabel23.setVisible(false);
            
            ArrayList<String> kioscosArray = OracleMethods.todosLosKioscos();
            for (int i = 0; i < kioscosArray.size(); i++)
                infoBox.addItem(kioscosArray.get(i)); 
        }
        else {
            this.jPanel1.setBorder(BorderFactory.createTitledBorder("Manejo pedidos"));
            this.jLabel1.setText("Cliente:");
            this.manejoMantenimiento_Pane.remove(infoMant_Panel);
            this.manejoMantenimiento_Pane.remove(creacionMant_Panel);
            infoBox.addItem("RIF - Cliente");
            infoBox.setSelectedItem("RIF - Cliente");     
            this.manejoMantenimiento_Pane.setEnabledAt(1, false);
            this.panelManejoMantenimiento.setVisible(false);
            this.panelManejoPedido.setVisible(true);
            
            ArrayList<String> clientsArray = OracleMethods.todosLosClientes();
            for (int i = 0; i < clientsArray.size(); i++)
                infoBox.addItem(clientsArray.get(i));
        }
    }
    
    public void limpiarCamposInfoMantenimiento() {
        this.registrarMantButton.setEnabled(true);
        this.registrarMantButton.setText("Registrar");
        this.registrarMantButton.setVisible(true);
        this.editarMantButton.setText("Editar");
        this.editarMantButton.setVisible(true);
        this.eliminarMantButton.setVisible(true);
        this.infoMant_Text.setText("");
    }
    
    public void limpiarCamposCreacionMantenimiento() {
        this.tiposMantBox.setSelectedItem("Tipo - Mantenimiento");
        this.kioscosBox.setSelectedItem("Kiosco - Nombre");
        this.empleadosCIBox.setSelectedItem("CI - Empleado");
        this.fechaMantChooser.setDate(null);
        this.costoHoraEmpText.setText("");
        this.costoHoraClienteText.setText("");
        this.horasSpinner.setValue(0);
        montoTotalField.setText("");
        this.jLabel22.setVisible(false);
        this.jLabel23.setVisible(false);
    }
    
    public void eliminarInfoCreacionMantenimiento() {
        this.tiposMantBox.removeAllItems();
        this.kioscosBox.removeAllItems();
        this.empleadosCIBox.removeAllItems();
        this.fechaMantChooser.setDate(null);
        this.costoHoraClienteText.setText("");
        this.horasSpinner.setValue(0);
        montoTotalField.setText("");
        this.jLabel22.setVisible(false);
        this.jLabel23.setVisible(false);
    }
    
    public void limpiarCamposCreacionPedido() {
        this.materialBox.setSelectedItem("Elegir material");
        this.tamanoBox.setSelectedItem("Elegir tamaño");
        this.cantidadBox.setSelectedIndex(0);
        this.fechaCchooser.setDate(null);
        this.fechaEchooser.setDate(null);
        this.clientesBox.setEnabled(true);
        this.costoField.setText("");
        this.fechaEchooser.setEnabled(false);
    }
    
    public void limpiarCamposInfoPedido() {
        this.registrarPedidoButton.setEnabled(true);
        this.registrarPedidoButton.setText("Registrar");
        this.registrarPedidoButton.setVisible(true);
        this.editarPedidoButton.setText("Editar");
        this.editarPedidoButton.setVisible(true);
        this.eliminarPedidoButton.setVisible(true);
        this.infoPedido_Text.setText("");
    }
    
    public final void mostrarInfoMantenimiento(String busqueda) throws SQLException{
        this.infoMant_Table.removeAll();
        
        if (!busqueda.equals("Kiosco")){
            DefaultTableModel dm = new DefaultTableModel();
            dm.addColumn("Fecha del Mantenimiento");
            dm.addColumn("Tipo de Mantenimiento");
            dm.addColumn("CI empleado");
            dm.addColumn("Horas T.");
        
            Connection con = OracleMethods.oracleConnection();
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT fecha_PK, horas, ci_PK_FK, tipo "
                + "FROM ao_mant_kiosco,ao_mantenimiento "
                + "WHERE ao_mant_kiosco.mant_PK_FK = ao_mantenimiento.mantenimiento_PK "
                + "AND ao_mant_kiosco.kiosco_PK_FK = " + busqueda);


            while(rs.next()) {
                Vector row = new Vector();
                row.add(rs.getDate("fecha_PK"));
                row.add(rs.getString("tipo"));
                row.add(rs.getString("ci_PK_FK"));
                row.add(rs.getString("horas"));
                dm.addRow(row);
            }

            this.infoMant_Table.setModel(dm);
            this.infoMant_Table.setVisible(true);

            stmt.close();
            rs.close();
            con.close();
        }
    }
    
    
    public final void mostrarInfoPedido(String busqueda) throws SQLException{
        this.infoPedido_Table.removeAll();
        
        if (!busqueda.equals("RIF")){
        
            DefaultTableModel dm = new DefaultTableModel();
            dm.addColumn("Nro.");
            dm.addColumn("Cantidad");
            dm.addColumn("Material");
            dm.addColumn("Fecha de creacion");
            dm.addColumn("Fecha de entrega");

            Connection con = OracleMethods.oracleConnection();
            Statement stmt = con.createStatement(); 
            ResultSet rs = stmt.executeQuery("SELECT pedido_PK, fecha_pedido, fecha_entrega, cantidad, material "
                    + "FROM ao_pedido, ao_detalle_pedido, ao_material WHERE "
                    + "ao_pedido.pedido_PK = ao_detalle_pedido.pedido_PK_FK AND "
                    + "ao_detalle_pedido.material_FK = ao_material.material_PK AND "
                    + "ao_pedido.rif_PK_FK = " + busqueda);

            while(rs.next()) { 
                Vector row = new Vector();
                row.add(rs.getInt("pedido_PK"));
                row.add(rs.getInt("cantidad"));
                row.add(rs.getString("material"));
                row.add(rs.getDate("fecha_pedido"));
                row.add(rs.getDate("fecha_entrega"));
                dm.addRow(row);
            }

            this.infoPedido_Table.setModel(dm);
            this.infoPedido_Table.setVisible(true);

            stmt.close();
            rs.close();
            con.close();
        }
    }
    
    public void infoCreacionMant() {
        try {           
            this.empleadosCIBox.removeAllItems();
            this.kioscosBox.removeAllItems();
            this.tiposMantBox.removeAllItems();
            
            ArrayList<String> infoArray = new ArrayList<String>();
            String[] splitString = null;
            
            if((empleadosCIBox.getSelectedItem() == null) && (kioscosBox.getSelectedItem() == null) 
                    && (tiposMantBox.getSelectedItem() == null)){
            
                //Mostrar todos los empleados en el ComboBox correspondiente.
                infoArray = OracleMethods.todosLosEmpleados();
                empleadosCIBox.addItem("CI - Empleado");
                empleadosCIBox.setSelectedItem("CI - Empleado");
                for (int i = 0; i < infoArray.size(); i++)
                    empleadosCIBox.addItem(infoArray.get(i));

                //Mostrar todos los kioscos en el ComboBox correspondiente.
                infoArray = OracleMethods.todosLosKioscos();
                kioscosBox.addItem("Kiosco - Nombre");
                for (int i = 0; i < infoArray.size(); i++)
                    kioscosBox.addItem(infoArray.get(i));
                kioscosBox.setSelectedItem(infoBox.getSelectedItem());

                //Mostrar todos los tipos de Mantenimiento en el ComboBox correspondiente.
                infoArray = OracleMethods.todosLosMantenimientos();
                tiposMantBox.addItem("Tipo - Mantenimiento");
                tiposMantBox.setSelectedItem("Tipo - Mantenimiento");
                for (int i = 0; i < infoArray.size(); i++){
                    splitString = infoArray.get(i).split(";");
                    tiposMantBox.addItem(splitString[0] + " - " + splitString[1]);
                }
            }
            
        } catch (SQLException ex) {
            System.out.println(ex);
        }
    }
    
    public void infoCreacionPedido() {
        try {
            ArrayList<String> infoArray = new ArrayList<String>();
            
            if((materialBox.getSelectedItem() == null) && (tamanoBox.getSelectedItem() == null) 
                    && (clientesBox.getSelectedItem() == null)){
            
                //Mostrar todos los materiales de vallas en el ComboBox correspondiente.
                infoArray = OracleMethods.todosLosMateriales();
                materialBox.addItem("Elegir material");
                materialBox.setSelectedItem("Elegir material");
                for (int i = 0; i < infoArray.size(); i++){
                    materialBox.addItem(infoArray.get(i));
                }
            
                infoArray = OracleMethods.todosLosTamanos();
                tamanoBox.addItem("Elegir tamaño");
                tamanoBox.setSelectedItem("Elegir tamaño");
                for (int i = 0; i < infoArray.size(); i++){
                    tamanoBox.addItem(infoArray.get(i));
                }
            
                //Mostrar todos los clientes en e ComboBox correspondiente.
                for (int i = 0; i < infoBox.getItemCount(); i++){
                    clientesBox.addItem(infoBox.getItemAt(i));
                }
            
                costoField.setText("");
            }
            
        } catch (SQLException ex) {
            System.out.println(ex);
        }
        
        
    }
    
    public String calcularCostoPedido(Integer cantidad) {
        String[] infoVallaMaterial = null;
        Integer costoPedido = 0;
        try {
            String material_PK = materialBox.getSelectedItem().toString().substring(0,1);
            String valla_PK = tamanoBox.getSelectedItem().toString().substring(0,1);
            
            infoVallaMaterial = OracleMethods.buscarCostoPedido(material_PK,valla_PK).split(";");
            
        } catch (SQLException ex) {
            System.out.println(ex);
        }
        
        if (infoVallaMaterial != null){
            costoPedido = (Integer.parseInt(infoVallaMaterial[1]) * cantidad);
        }
        return costoPedido.toString();
    }
    
    public String calcularMontoMantenimiento() {
        Integer costoHoraEmp = Integer.parseInt(this.costoHoraEmpText.getText());
        Integer costoHoraCliente = Integer.parseInt(this.costoHoraClienteText.getText());
        Integer horasTrabajadas = (Integer) this.horasSpinner.getValue();
        
        return String.valueOf((costoHoraEmp + costoHoraCliente) * horasTrabajadas);
    }
    
    public void mostrarInfoEdicionMant(String nroKiosco, String ciEmpleado, String tipoMant, 
            String fechaMant, String costoHoraEmp, String costoHoraCliente, Integer horasT) {
        
        try {
            for (int i = 0; i < kioscosBox.getItemCount(); i++){
                if (kioscosBox.getItemAt(i).toString().substring(0, kioscosBox.getItemAt(i).toString().indexOf(" ")).equals(nroKiosco)){
                    kioscosBox.setSelectedItem(kioscosBox.getItemAt(i));
                    break;
                }
            }
            
            for (int i = 0; i < empleadosCIBox.getItemCount(); i++){
                if (empleadosCIBox.getItemAt(i).toString().substring(0, empleadosCIBox.getItemAt(i).toString().indexOf(" ")).equals(ciEmpleado)){
                    empleadosCIBox.setSelectedItem(empleadosCIBox.getItemAt(i));
                    break;
                }
            }
            
            for (int i = 0; i < tiposMantBox.getItemCount(); i++){
                if (tiposMantBox.getItemAt(i).toString().contains(tipoMant)){
                    tiposMantBox.setSelectedItem(tiposMantBox.getItemAt(i));
                    break;
                }
            }         
            
            this.fechaMantChooser.setDate(fecha2.parse(fechaMant));
            this.costoHoraEmpText.setText(costoHoraEmp);
            this.costoHoraClienteText.setText(costoHoraCliente);
            this.horasSpinner.setValue(horasT);
            
        } catch (ParseException ex) {
            System.out.println(ex);
        }
        
        
        
    }
    
    public void validarEmpleadosDisponibles() {
        try {
            String ciEmpleadoSelected = null;
            String ciEmpleado = null;
            int repeticion = 0;
            
            empleadosCIBox.removeAllItems();
            ArrayList<String> infoArray = OracleMethods.todosLosEmpleados();
            empleadosCIBox.addItem("CI - Empleado");
            for (int i = 0; i < infoArray.size(); i++)
               empleadosCIBox.addItem(infoArray.get(i));
            
            String fechaMantenimiento = fecha.format(fechaMantChooser.getDate());
            String[] empleadosOcupados = OracleMethods.buscarEmpleadosOcupados(fechaMantenimiento).split(";");
      
            if(this.infoMant_Table.getSelectedRow() != -1){
                int row = this.infoMant_Table.getSelectedRow();
                ciEmpleado =  this.infoMant_Table.getModel().getValueAt(row, 2).toString();
            }
            
            for (int i = 1; i < empleadosCIBox.getItemCount(); i++){
                for (int j = 0; j < empleadosOcupados.length; ++j){
                    ciEmpleadoSelected = empleadosCIBox.getItemAt(i).toString().substring(0, empleadosCIBox.getItemAt(i).toString().toString().indexOf(" "));
                        
                    if ((ciEmpleadoSelected.equals(empleadosOcupados[j].toString()))){
                        empleadosCIBox.removeItemAt(i);
                        i--;
                    }
                
                    j = j + 1;
                }

                if (empleadosCIBox.getItemAt(i).toString().equals(ciEmpleado))
                    repeticion ++;
                
            }
             
                    
             if ((repeticion == 0) && (ciEmpleado != null))
                this.empleadosCIBox.addItem(ciEmpleado);
        } catch (SQLException ex) {
            System.out.println(ex);
        }
            
    }
    
    public void validarKioscosEnMantenimiento() {
        try {
            this.kioscosBox.removeAllItems();
            
            ArrayList<String> infoArray = OracleMethods.todosLosKioscos();
            kioscosBox.addItem("Kiosco - Nombre");
            for (int i = 0; i < infoArray.size(); i++)
                kioscosBox.addItem(infoArray.get(i));
            
            if ((!tiposMantBox.getSelectedItem().equals("Tipo - Mantenimiento")) && (fechaMantChooser.getDate() != null)){
                Integer nroTipoMant = Integer.parseInt(tiposMantBox.getSelectedItem().toString().substring(0, tiposMantBox.getSelectedItem().toString().indexOf(" ")));
                String fechaC = fecha.format(fechaMantChooser.getDate());
                
                String[] kioscosOcupados = OracleMethods.buscarKioscosOcupados(nroTipoMant, fechaC).split(";");
                
                for (int i = 1; i < kioscosBox.getItemCount(); i++){
                    for (int j = 0; j < kioscosOcupados.length; ++j){

                            if ((kioscosBox.getItemAt(i).toString().substring(0, kioscosBox.getItemAt(i).toString().indexOf(" ")).equals(kioscosOcupados[j].toString()))){
                                kioscosBox.removeItemAt(i);
                                i--;
                            }

                        j = j + 1;

                    }
                }
            }
            
        } catch (SQLException ex) {
            System.out.println(ex);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        manejoMantenimiento_Pane = new javax.swing.JTabbedPane();
        infoMant_Panel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        infoMant_Table = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        infoMant_Text = new javax.swing.JTextArea();
        creacionMant_Panel = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        empleadosCIBox = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        horasSpinner = new javax.swing.JSpinner();
        jLabel8 = new javax.swing.JLabel();
        kioscosBox = new javax.swing.JComboBox();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        tiposMantBox = new javax.swing.JComboBox();
        costoHoraEmpText = new javax.swing.JTextField();
        costoHoraClienteText = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        montoTotalField = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        fechaMantChooser = new com.toedter.calendar.JDateChooser();
        infoPedido_Panel = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        infoPedido_Table = new javax.swing.JTable();
        jScrollPane4 = new javax.swing.JScrollPane();
        infoPedido_Text = new javax.swing.JTextArea();
        creacionPedido_Panel = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        clientesBox = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        fechaEchooser = new com.toedter.calendar.JDateChooser();
        jLabel5 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        fechaCchooser = new com.toedter.calendar.JDateChooser();
        jPanel3 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        materialBox = new javax.swing.JComboBox();
        tamanoBox = new javax.swing.JComboBox();
        cantidadBox = new javax.swing.JComboBox();
        costoField = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        infoBox = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        backButton = new javax.swing.JButton();
        panelManejoMantenimiento = new javax.swing.JPanel();
        registrarMantButton = new javax.swing.JButton();
        eliminarMantButton = new javax.swing.JButton();
        editarMantButton = new javax.swing.JButton();
        panelManejoPedido = new javax.swing.JPanel();
        registrarPedidoButton = new javax.swing.JButton();
        eliminarPedidoButton = new javax.swing.JButton();
        editarPedidoButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setBounds(new java.awt.Rectangle(0, 22, 750, 500));
        setMinimumSize(new java.awt.Dimension(689, 500));
        setSize(new java.awt.Dimension(750, 610));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("..."));
        jPanel1.setMinimumSize(new java.awt.Dimension(649, 343));

        manejoMantenimiento_Pane.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                manejoMantenimiento_PaneStateChanged(evt);
            }
        });

        infoMant_Panel.setLayout(null);

        infoMant_Table.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        infoMant_Table.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN);
        infoMant_Table.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                infoMant_TableMouseReleased(evt);
            }
        });
        jScrollPane1.setViewportView(infoMant_Table);

        infoMant_Panel.add(jScrollPane1);
        jScrollPane1.setBounds(0, 0, 390, 340);

        infoMant_Text.setBackground(new java.awt.Color(204, 204, 204));
        infoMant_Text.setColumns(20);
        infoMant_Text.setEditable(false);
        infoMant_Text.setRows(5);
        infoMant_Text.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jScrollPane3.setViewportView(infoMant_Text);

        infoMant_Panel.add(jScrollPane3);
        jScrollPane3.setBounds(391, 0, 270, 340);

        manejoMantenimiento_Pane.addTab("Info. Mantenimiento", infoMant_Panel);

        creacionMant_Panel.setLayout(null);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Info. Destinatario"));

        jLabel7.setText("CI empleado:");

        empleadosCIBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                empleadosCIBoxActionPerformed(evt);
            }
        });

        jLabel9.setText("Horas trabajadas:");

        horasSpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 24, 1));
        horasSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                horasSpinnerStateChanged(evt);
            }
        });

        jLabel8.setText("Kiosco:");

        jLabel22.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        jLabel22.setText("No existen empleados disponibles para esta fecha.");

        jLabel23.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
        jLabel23.setText("No existen kioscos disponibles para esta fecha");

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel23)
                            .add(jPanel4Layout.createSequentialGroup()
                                .add(jLabel8)
                                .add(54, 54, 54)
                                .add(kioscosBox, 0, 181, Short.MAX_VALUE)))
                        .addContainerGap())
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel4Layout.createSequentialGroup()
                                .add(jLabel7)
                                .add(18, 18, 18)
                                .add(empleadosCIBox, 0, 184, Short.MAX_VALUE))
                            .add(jLabel22)
                            .add(jPanel4Layout.createSequentialGroup()
                                .add(jLabel9)
                                .add(18, 18, 18)
                                .add(horasSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                        .add(14, 14, 14))))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel8)
                    .add(kioscosBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel23)
                .add(18, 18, 18)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel7)
                    .add(empleadosCIBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel22)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 28, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(horasSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(54, Short.MAX_VALUE))
        );

        creacionMant_Panel.add(jPanel4);
        jPanel4.setBounds(310, 20, 330, 240);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Info.Mantenimiento"));

        jLabel2.setText("Tipo:");

        jLabel3.setText("Costo/Hora  (Empleado):");

        jLabel4.setText("Costo/Hora (Cliente):");

        tiposMantBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tiposMantBoxActionPerformed(evt);
            }
        });

        costoHoraEmpText.setEditable(false);

        costoHoraClienteText.setEditable(false);

        jLabel10.setFont(new java.awt.Font("Lucida Grande", 0, 10));
        jLabel10.setText("Bs.");

        jLabel11.setFont(new java.awt.Font("Lucida Grande", 0, 10));
        jLabel11.setText("Bs.");

        jLabel19.setText("Monto Total:");

        montoTotalField.setEditable(false);
        montoTotalField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                montoTotalFieldActionPerformed(evt);
            }
        });

        jLabel20.setFont(new java.awt.Font("Lucida Grande", 0, 10));
        jLabel20.setText("Bs.");

        jLabel21.setText("Fecha:");

        fechaMantChooser.setDateFormatString("dd/MM/yyyy");
        fechaMantChooser.setMinSelectableDate(new Date());
        fechaMantChooser.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                fechaMantChooserPropertyChange(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                .add(69, 69, 69)
                .add(jLabel19)
                .add(18, 18, 18)
                .add(montoTotalField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel20)
                .add(22, 22, 22))
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel3)
                    .add(jLabel4))
                .add(18, 18, 18)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(costoHoraClienteText)
                    .add(costoHoraEmpText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel10)
                    .add(jLabel11))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel21)
                    .add(jLabel2))
                .add(18, 18, 18)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(tiposMantBox, 0, 165, Short.MAX_VALUE)
                    .add(fechaMantChooser, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE))
                .add(31, 31, 31))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2)
                    .add(tiposMantBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel21, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
                    .add(fechaMantChooser, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .add(18, 18, 18)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel3)
                    .add(costoHoraEmpText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel11))
                .add(18, 18, 18)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(costoHoraClienteText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel10))
                .add(53, 53, 53)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel19)
                    .add(montoTotalField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel20))
                .addContainerGap())
        );

        creacionMant_Panel.add(jPanel5);
        jPanel5.setBounds(20, 20, 280, 310);

        manejoMantenimiento_Pane.addTab("", creacionMant_Panel);

        infoPedido_Panel.setLayout(null);

        infoPedido_Table.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        infoPedido_Table.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                infoPedido_TableMouseReleased(evt);
            }
        });
        jScrollPane2.setViewportView(infoPedido_Table);

        infoPedido_Panel.add(jScrollPane2);
        jScrollPane2.setBounds(0, 0, 390, 340);

        infoPedido_Text.setBackground(new java.awt.Color(204, 204, 204));
        infoPedido_Text.setColumns(20);
        infoPedido_Text.setEditable(false);
        infoPedido_Text.setRows(5);
        infoPedido_Text.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jScrollPane4.setViewportView(infoPedido_Text);

        infoPedido_Panel.add(jScrollPane4);
        jScrollPane4.setBounds(391, 0, 270, 340);

        manejoMantenimiento_Pane.addTab("Info. Pedido", infoPedido_Panel);

        creacionPedido_Panel.setLayout(null);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Info. Destinatario"));

        jLabel13.setText("Cliente:");

        fechaEchooser.setDateFormatString("dd/MM/yyyy");
        fechaEchooser.setEnabled(false);
        fechaEchooser.setMaxSelectableDate(new java.util.Date(1577856707000L));
        fechaEchooser.setMinSelectableDate(new Date());

        jLabel5.setText("Fecha de creacion:");

        jLabel12.setText("Fecha de entrega:");

        fechaCchooser.setDateFormatString("dd/MM/yyyy");
        fechaCchooser.setMaxSelectableDate(new java.util.Date(1577856713000L));
        fechaCchooser.setMinSelectableDate(new Date());
        fechaCchooser.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                fechaCchooserPropertyChange(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel13)
                        .add(18, 18, 18)
                        .add(clientesBox, 0, 215, Short.MAX_VALUE))
                    .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                        .add(jPanel2Layout.createSequentialGroup()
                            .add(jLabel12)
                            .add(24, 24, 24)
                            .add(fechaEchooser, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel2Layout.createSequentialGroup()
                            .add(jLabel5)
                            .add(18, 18, 18)
                            .add(fechaCchooser, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(22, 22, 22)
                        .add(jLabel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 26, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(fechaCchooser, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(20, 20, 20)
                        .add(jLabel12))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(14, 14, 14)
                        .add(fechaEchooser, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(22, 22, 22)
                        .add(jLabel13))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(18, 18, 18)
                        .add(clientesBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        creacionPedido_Panel.add(jPanel2);
        jPanel2.setBounds(310, 20, 330, 180);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Info. Pedido"));

        jLabel14.setText("Material:");

        jLabel15.setText("Tamaño:");

        jLabel16.setText("Cantidad:");

        jLabel17.setText("Monto Total:");

        materialBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                materialBoxActionPerformed(evt);
            }
        });

        tamanoBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tamanoBoxActionPerformed(evt);
            }
        });

        cantidadBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        cantidadBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cantidadBoxActionPerformed(evt);
            }
        });

        costoField.setEditable(false);

        jLabel18.setFont(new java.awt.Font("Lucida Grande", 0, 10));
        jLabel18.setText("Bs.");

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(20, 20, 20)
                        .add(jLabel16)
                        .add(18, 18, 18)
                        .add(cantidadBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel3Layout.createSequentialGroup()
                                .add(20, 20, 20)
                                .add(jLabel15))
                            .add(jPanel3Layout.createSequentialGroup()
                                .addContainerGap()
                                .add(jLabel14)))
                        .add(24, 24, 24)
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(materialBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 142, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(tamanoBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 120, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(65, Short.MAX_VALUE)
                .add(jLabel17)
                .add(18, 18, 18)
                .add(costoField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel18, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel14)
                    .add(materialBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(4, 4, 4)
                        .add(jLabel15))
                    .add(tamanoBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(4, 4, 4)
                        .add(jLabel16))
                    .add(cantidadBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 102, Short.MAX_VALUE)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(costoField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel18))
                .add(19, 19, 19))
        );

        creacionPedido_Panel.add(jPanel3);
        jPanel3.setBounds(20, 20, 280, 310);

        manejoMantenimiento_Pane.addTab("", creacionPedido_Panel);

        jLabel1.setText("jLabel1");

        infoBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                infoBoxActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Lucida Grande", 0, 10));
        jLabel6.setText("Porfavor seleccione una opcion de la lista.");

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(29, 29, 29)
                        .add(jLabel1)
                        .add(18, 18, 18)
                        .add(infoBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 228, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel6))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, manejoMantenimiento_Pane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 685, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(infoBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel6))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(manejoMantenimiento_Pane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 407, Short.MAX_VALUE)
                .addContainerGap())
        );

        backButton.setText("Atras");
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backButtonActionPerformed(evt);
            }
        });

        registrarMantButton.setText("Registrar");
        registrarMantButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                registrarMantButtonActionPerformed(evt);
            }
        });

        eliminarMantButton.setText("Eliminar");
        eliminarMantButton.setEnabled(false);
        eliminarMantButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliminarMantButtonActionPerformed(evt);
            }
        });

        editarMantButton.setText("Editar");
        editarMantButton.setEnabled(false);
        editarMantButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarMantButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout panelManejoMantenimientoLayout = new org.jdesktop.layout.GroupLayout(panelManejoMantenimiento);
        panelManejoMantenimiento.setLayout(panelManejoMantenimientoLayout);
        panelManejoMantenimientoLayout.setHorizontalGroup(
            panelManejoMantenimientoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelManejoMantenimientoLayout.createSequentialGroup()
                .add(registrarMantButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(editarMantButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(eliminarMantButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
        panelManejoMantenimientoLayout.setVerticalGroup(
            panelManejoMantenimientoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelManejoMantenimientoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                .add(registrarMantButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(editarMantButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(eliminarMantButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );

        registrarPedidoButton.setText("Registrar");
        registrarPedidoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                registrarPedidoButtonActionPerformed(evt);
            }
        });

        eliminarPedidoButton.setText("Eliminar");
        eliminarPedidoButton.setEnabled(false);
        eliminarPedidoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliminarPedidoButtonActionPerformed(evt);
            }
        });

        editarPedidoButton.setText("Editar");
        editarPedidoButton.setEnabled(false);
        editarPedidoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarPedidoButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout panelManejoPedidoLayout = new org.jdesktop.layout.GroupLayout(panelManejoPedido);
        panelManejoPedido.setLayout(panelManejoPedidoLayout);
        panelManejoPedidoLayout.setHorizontalGroup(
            panelManejoPedidoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelManejoPedidoLayout.createSequentialGroup()
                .add(registrarPedidoButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(editarPedidoButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(eliminarPedidoButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
        panelManejoPedidoLayout.setVerticalGroup(
            panelManejoPedidoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelManejoPedidoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                .add(registrarPedidoButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(editarPedidoButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(eliminarPedidoButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(panelManejoMantenimiento, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(panelManejoPedido, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 126, Short.MAX_VALUE)
                        .add(backButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(panelManejoMantenimiento, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(backButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(panelManejoPedido, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
    jLabel1.setText("");
    this.dispose();
}//GEN-LAST:event_backButtonActionPerformed

private void infoPedido_TableMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_infoPedido_TableMouseReleased
    String[] infoClient = null;
    String[] infoPedido = null;
    String[] caracteristicasPedido = null;
    infoPedido_Text.setText("");
    int row = this.infoPedido_Table.getSelectedRow();
    
    String infoText = (String) this.infoBox.getSelectedItem();
    String rifCliente = infoText.substring(0, infoText.indexOf(" "));
    
    String nroPedido = (String) this.infoPedido_Table.getModel().getValueAt(row, 0).toString();
    String cantidad = (String) this.infoPedido_Table.getModel().getValueAt(row, 1).toString();
    String material = (String) this.infoPedido_Table.getModel().getValueAt(row, 2).toString();
    String fechaC = (String) this.infoPedido_Table.getModel().getValueAt(row, 3).toString();
    String fechaE = (String) this.infoPedido_Table.getModel().getValueAt(row, 4).toString();
    
    this.editarPedidoButton.setEnabled(true);
    this.eliminarPedidoButton.setEnabled(true);
    
    try {
        String infoCliente = OracleMethods.buscarCliente(rifCliente);
        infoClient = infoCliente.split(";");
        
        caracteristicasPedido = OracleMethods.buscarCaracteristicasPedido(nroPedido, rifCliente).split(";");
        if (caracteristicasPedido != null){
            infoPedido = OracleMethods.buscarCostoPedido(caracteristicasPedido[1], caracteristicasPedido[0]).split(";");
        }
        } catch (SQLException ex) {
            System.out.println(ex);
        }   
    if ((infoPedido != null) & (caracteristicasPedido != null)){
        infoPedido_Text.setText("*Informacion del pedido:\n     " +
                "\n     - Numero del pedido:  #" + nroPedido + " \n" +
                "\n     - Cantidad:  " + cantidad + " \n" +
                "\n     - Tipo de material:  " + material + " \n" +
                "\n     - Tamano:  " + caracteristicasPedido[2] + " \n" +
                "\n     - Monto Total:  " + infoPedido[1] + " \n" +
                "\n     - Fecha de Creacion:  " + fechaC + " \n" +
                "\n     - Fecha de Entrega:  " + fechaE + " \n" +
                "\n*Cliente destino:\n       " + 
                "\n     - RIF: " + rifCliente + " \n" +
                "\n     - Nombre de la empresa: " + infoClient[0] + " " + " \n" +
                "\n     - Persona de Contacto: " + infoClient[1] + " " + " \n" +
                "\n     - Telefono principal: " + infoClient[2] + " " + " \n" +
                "\n     - Telefono de secundario: " + infoClient[3] + " " + " \n");
    }
}//GEN-LAST:event_infoPedido_TableMouseReleased

private void infoMant_TableMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_infoMant_TableMouseReleased
    String[] infoEmp = null;
    infoMant_Text.setText("");    
    int row = this.infoMant_Table.getSelectedRow();
    String infoFecha = (String) this.infoMant_Table.getModel().getValueAt(row, 0).toString();
    String infoTipo = (String) this.infoMant_Table.getModel().getValueAt(row, 1).toString();
    String ciEmpleado = (String) this.infoMant_Table.getModel().getValueAt(row, 2).toString();
    
    this.editarMantButton.setEnabled(true);
    this.eliminarMantButton.setEnabled(true);
        
    try {
        String infoEmpleado = OracleMethods.buscarEmpleado(ciEmpleado);
        infoEmp = infoEmpleado.split(";");
        } catch (SQLException ex) {
            System.out.println(ex);
        }
    
    infoMant_Text.setText("*Informacion del mantenimiento:\n     " +
            "\n     - Kiosco del mantenimiento:\n       " + this.infoBox.getSelectedItem() + " \n" +
            "\n     - Fecha del mantenimiento:\n       " + infoFecha + " \n" +
            "\n     - Tipo del mantenimiento:\n       " + infoTipo + " \n" +
            "\n*Empleado encargado:\n       " + 
            "\n     - Cedula de Identidad: " + ciEmpleado + " \n" + 
            "\n     - Nombre del empleado: " + infoEmp[0] + " " + infoEmp[1] + " \n" +
            "\n     - Telefono: " + infoEmp[2] + " \n");
}//GEN-LAST:event_infoMant_TableMouseReleased

private void infoBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_infoBoxActionPerformed
    try {
        if ((this.jLabel1.getText().equals("Kiosco:"))){
            mostrarInfoMantenimiento(this.infoBox.getSelectedItem().toString().substring(0, this.infoBox.getSelectedItem().toString().indexOf(" ")));
        }
            
        else if ((this.jLabel1.getText().equals("Cliente:"))){
            mostrarInfoPedido(this.infoBox.getSelectedItem().toString().substring(0, this.infoBox.getSelectedItem().toString().indexOf(" ")));
        }
        
        this.editarMantButton.setEnabled(false);
        this.eliminarMantButton.setEnabled(false);
        this.infoMant_Text.setText("");
        
    } catch (SQLException ex) {
            System.out.println(ex);
      }
}//GEN-LAST:event_infoBoxActionPerformed

private void manejoMantenimiento_PaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_manejoMantenimiento_PaneStateChanged
    if (this.creacionMant_Panel.isShowing()){
        infoBox.setEnabled(false);
        //infoCreacionMant();
      
        if (this.editarMantButton.getText().equals("Editar")){
            this.registrarMantButton.setText("Confirmar");
            this.editarMantButton.setEnabled(false);
            this.eliminarMantButton.setEnabled(false);
        }
    }
    else if (this.infoMant_Panel.isShowing()){
        infoBox.setEnabled(true);
        this.registrarMantButton.setText("Registrar");
        this.editarMantButton.setText("Editar");
        this.registrarMantButton.setEnabled(true);  
        for (int i = 0; i < infoMant_Table.getModel().getRowCount(); i++){
            if (infoMant_Table.isRowSelected(i)){
                this.editarMantButton.setEnabled(true);
                this.eliminarMantButton.setEnabled(true);
            }
                
        }
    }
    
    else if (this.creacionPedido_Panel.isShowing()){
        infoCreacionPedido();
        infoBox.setEnabled(false);
        if (this.editarPedidoButton.getText().equals("Editar")){
            this.registrarPedidoButton.setText("Confirmar");
            this.editarPedidoButton.setEnabled(false);
            this.eliminarPedidoButton.setEnabled(false);
        }
    }
    
    else if (this.infoPedido_Panel.isShowing()){
        infoBox.setEnabled(true);
        this.registrarPedidoButton.setText("Registrar");
        this.editarPedidoButton.setText("Editar");
        this.registrarPedidoButton.setEnabled(true);  
        for (int i = 0; i < infoPedido_Table.getModel().getRowCount(); i++){
            if (infoPedido_Table.isRowSelected(i)){
                this.editarPedidoButton.setEnabled(true);
                this.eliminarPedidoButton.setEnabled(true);
            }
                
        }
    }
}//GEN-LAST:event_manejoMantenimiento_PaneStateChanged

private void cantidadBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cantidadBoxActionPerformed
    if ((tamanoBox.getSelectedItem() != null) && (materialBox.getSelectedItem() != null)) {
        if (!(tamanoBox.getSelectedItem().equals("Elegir tamaño")) && !(materialBox.getSelectedItem().equals("Elegir material"))){
            costoField.setText(calcularCostoPedido(Integer.parseInt(cantidadBox.getSelectedItem().toString())));
        
        }
        else
            costoField.setText("");
    }
}//GEN-LAST:event_cantidadBoxActionPerformed

private void tamanoBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tamanoBoxActionPerformed
    if ((tamanoBox.getSelectedItem() != null) && (materialBox.getSelectedItem() != null)){
        if (!(tamanoBox.getSelectedItem().equals("Elegir tamaño")) && !(materialBox.getSelectedItem().equals("Elegir material"))){
            costoField.setText(calcularCostoPedido(Integer.parseInt(cantidadBox.getSelectedItem().toString())));       
        }
        else
            costoField.setText("");
    }
}//GEN-LAST:event_tamanoBoxActionPerformed

private void materialBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_materialBoxActionPerformed
    if ((tamanoBox.getSelectedItem() != null) && (materialBox.getSelectedItem() != null)){
        if (!(tamanoBox.getSelectedItem().equals("Elegir tamaño")) && !(materialBox.getSelectedItem().equals("Elegir material"))){
            costoField.setText(calcularCostoPedido(Integer.parseInt(cantidadBox.getSelectedItem().toString())));   
        }
        else
            costoField.setText("");
    }
}//GEN-LAST:event_materialBoxActionPerformed

private void montoTotalFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_montoTotalFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_montoTotalFieldActionPerformed

private void tiposMantBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tiposMantBoxActionPerformed
    if((tiposMantBox.getSelectedItem() != null) && (empleadosCIBox.getSelectedItem() != null) 
            && (kioscosBox.getSelectedItem() != null)){
 
        if(!(tiposMantBox.getSelectedItem().equals("Tipo - Mantenimiento"))){

            int tipoMantSelected = this.tiposMantBox.getSelectedItem().toString().lastIndexOf(" ");
            String tipoMantenimiento = tiposMantBox.getSelectedItem().toString().substring((tipoMantSelected + 1), tiposMantBox.getSelectedItem().toString().length());
       
            try {
                String[] costos = OracleMethods.buscarCostosMant(tipoMantenimiento).split(";");
                this.costoHoraEmpText.setText(costos[0]);
                this.costoHoraClienteText.setText(costos[1]);
                
                validarKioscosEnMantenimiento();
                
                if(kioscosBox.getItemCount() == 1)
                    this.jLabel23.setVisible(true);
                else
                    this.jLabel23.setVisible(false);
                
            } catch (SQLException ex) {
                System.out.println(ex);
            }
            
            this.montoTotalField.setText(calcularMontoMantenimiento());
        }
    }
}//GEN-LAST:event_tiposMantBoxActionPerformed

private void horasSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_horasSpinnerStateChanged
    if(this.tiposMantBox.getSelectedItem() != null && this.empleadosCIBox.getSelectedItem() != null 
            && this.kioscosBox.getSelectedItem() != null)
        
        if((!tiposMantBox.getSelectedItem().equals("Tipo - Mantenimiento")))
            this.montoTotalField.setText(calcularMontoMantenimiento());
}//GEN-LAST:event_horasSpinnerStateChanged

private void registrarMantButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registrarMantButtonActionPerformed
    if (this.jLabel1.getText().equals("Kiosco:")){
        if(registrarMantButton.getText().equals("Registrar")){
            this.manejoMantenimiento_Pane.setEnabledAt(1, true);
            this.manejoMantenimiento_Pane.setSelectedIndex(1);
            this.eliminarMantButton.setEnabled(false);
            this.editarMantButton.setEnabled(false);
            this.manejoMantenimiento_Pane.setTitleAt(1, "Creacion mantenimiento");
            limpiarCamposCreacionMantenimiento();
            this.jLabel22.setVisible(false);
            this.jLabel23.setVisible(false);
            this.registrarMantButton.setText("Confirmar");
            this.editarMantButton.setText("Editar");
            infoCreacionMant();
            
        }
        else{
            
            if (tiposMantBox.getSelectedItem().equals("Tipo - Mantenimiento") || fechaMantChooser.getDate() == null 
                    || kioscosBox.getSelectedItem().equals("Kiosco - Nombre") || empleadosCIBox.getSelectedItem().equals("CI - Empleado"))
                
                    JOptionPane.showMessageDialog(this, "Error, campos incompletos o erroneos");
            
            else{ 
                try {
                    String fechaMant = fecha.format(fechaMantChooser.getDate());
                    Integer nroKiosco = Integer.parseInt(kioscosBox.getSelectedItem().toString().substring(0,1));
                    String ciEmpleado = empleadosCIBox.getSelectedItem().toString().substring(0,empleadosCIBox.getSelectedItem().toString().indexOf(" "));
                    Integer tipoMant = Integer.parseInt(tiposMantBox.getSelectedItem().toString().substring(0,1));
                    Integer horas = Integer.parseInt(horasSpinner.getValue().toString());        
                    String montoTotal = montoTotalField.getText();
        
                    int resultado = CreacionInformacion.crearMantenimiento(fechaMant, nroKiosco, ciEmpleado, tipoMant, horas, montoTotal);
        
                    if (resultado != 0){
                        JOptionPane.showMessageDialog(this, "Registro Exitoso");
                        limpiarCamposCreacionMantenimiento();
                        limpiarCamposInfoMantenimiento();
                        this.manejoMantenimiento_Pane.setSelectedIndex(0);
                        this.mostrarInfoMantenimiento(infoBox.getSelectedItem().toString().substring(0, infoBox.getSelectedItem().toString().indexOf(" ")));
                        this.manejoMantenimiento_Pane.setEnabledAt(1, false);
                        this.manejoMantenimiento_Pane.setTitleAt(1, "");
                    }
                    else
                        JOptionPane.showMessageDialog(this, "No se pudo realizar el registro");

                } catch (SQLException ex) {
                    System.out.println(ex);
                }
            }
        }
    }
}//GEN-LAST:event_registrarMantButtonActionPerformed

private void editarMantButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarMantButtonActionPerformed
    int row = this.infoMant_Table.getSelectedRow();
    
    String tipoMantenimiento =  this.infoMant_Table.getModel().getValueAt(row, 1).toString();
    
    
    if (editarMantButton.getText().equals("Editar")){
        this.manejoMantenimiento_Pane.setEnabledAt(1, true);
        this.manejoMantenimiento_Pane.setSelectedIndex(1);
        this.eliminarMantButton.setEnabled(false);
        this.registrarMantButton.setEnabled(false);
        this.editarMantButton.setEnabled(true);
        this.manejoMantenimiento_Pane.setTitleAt(1, "Edicion de mantenimiento");
        this.editarMantButton.setText("Confirmar");
        this.registrarMantButton.setText("Registrar");
        
        String nroKiosco = this.infoBox.getSelectedItem().toString().substring(0, infoBox.getSelectedItem().toString().indexOf(" "));
        String tipoMant = this.infoMant_Table.getModel().getValueAt(row, 1).toString();
        String ciEmpleado = (String) this.infoMant_Table.getModel().getValueAt(row, 2).toString();
        Integer horas = Integer.parseInt(this.infoMant_Table.getModel().getValueAt(row, 3).toString());
        String fechaMant =  this.infoMant_Table.getModel().getValueAt(row, 0).toString();

        try {
            infoMant = OracleMethods.buscarCostosMant(tipoMantenimiento).split(";");
        } catch (SQLException ex) {
            System.out.println(ex);
        }
            
        if(infoMant != null){
            this.mostrarInfoEdicionMant(nroKiosco, ciEmpleado, tipoMant, fechaMant, infoMant[0], infoMant[1], horas);
                    
            this.calcularMontoMantenimiento();
            nroMantAnterior = Integer.parseInt(tiposMantBox.getSelectedItem().toString().substring(0, tiposMantBox.getSelectedItem().toString().indexOf(" ")));
            nroKioscoAnterior = Integer.parseInt(kioscosBox.getSelectedItem().toString().substring(0, kioscosBox.getSelectedItem().toString().indexOf(" ")));
            ciEmpleadoAnterior = empleadosCIBox.getSelectedItem().toString().substring(0, empleadosCIBox.getSelectedItem().toString().indexOf(" "));
            horasTAnterior = (Integer) horasSpinner.getValue();
            fechaMantAnterior = fecha.format(fechaMantChooser.getDate());
            
            int tipoMantSelected = this.tiposMantBox.getSelectedItem().toString().lastIndexOf(" ");
            tipoMantAnterior = tiposMantBox.getSelectedItem().toString().substring((tipoMantSelected + 1), tiposMantBox.getSelectedItem().toString().length());
            
            montoMantAnterior = Integer.parseInt(montoTotalField.getText());
            
        }
    }
    else {
        if((tiposMantBox.getSelectedItem().equals("Tipo - Mantenimiento")) || (kioscosBox.getSelectedItem().equals("Kiosco - Nombre")) 
            || ((empleadosCIBox.getSelectedItem().equals("Seleccione una posicion"))) 
            || (fechaMantChooser.getDate() == null)){

            JOptionPane.showMessageDialog(this, "Error, campos incompletos o erroneos");
        }
        else{
            try {   
                Integer nroMant = Integer.parseInt(tiposMantBox.getSelectedItem().toString().substring(0, tiposMantBox.getSelectedItem().toString().indexOf(" ")));
                String fechaMant = fecha.format(this.fechaMantChooser.getDate());
                Integer nroKiosco = Integer.parseInt(kioscosBox.getSelectedItem().toString().substring(0,kioscosBox.getSelectedItem().toString().indexOf(" ")));
                String ciEmpleado = empleadosCIBox.getSelectedItem().toString().substring(0, empleadosCIBox.getSelectedItem().toString().indexOf(" "));  
                Integer montoMant = Integer.parseInt(montoTotalField.getText());
                Integer horasT = (Integer) horasSpinner.getValue();
                
                int tipoMantSelected = this.tiposMantBox.getSelectedItem().toString().lastIndexOf(" ");
                String tipoMant = tiposMantBox.getSelectedItem().toString().substring((tipoMantSelected + 1), tiposMantBox.getSelectedItem().toString().length());
                
                int resultado = EdicionInformacion.editarMantenimiento(nroMant, fechaMant, nroKiosco, ciEmpleado, 
                        montoMant, horasT, tipoMant, nroMantAnterior, nroKioscoAnterior, 
                        ciEmpleadoAnterior, horasTAnterior, fechaMantAnterior, tipoMantAnterior, montoMantAnterior);        
                
                if (resultado != 0){
                    JOptionPane.showMessageDialog(this, "Edición Exitosa");
                    limpiarCamposInfoMantenimiento();
                    limpiarCamposCreacionMantenimiento();
                    this.manejoMantenimiento_Pane.setSelectedIndex(0);
                    this.mostrarInfoMantenimiento(String.valueOf(nroKiosco));  
                    this.infoMant_Text.setText("");
                    this.manejoMantenimiento_Pane.setEnabledAt(1, false);
                    this.manejoMantenimiento_Pane.setTitleAt(1, "");
                }
            } catch (SQLException ex) {
                System.out.println(ex);
            }
        }
    }
}//GEN-LAST:event_editarMantButtonActionPerformed

private void eliminarMantButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliminarMantButtonActionPerformed
    this.registrarMantButton.setEnabled(false);
    this.editarMantButton.setEnabled(false);
    
    int confirmacion = JOptionPane.showConfirmDialog(this, "¿Desea eliminar ésta informacion de alquiler?");

    if(confirmacion == 0){
        int row = this.infoMant_Table.getSelectedRow();
        
        String fechaMant = this.infoMant_Table.getModel().getValueAt(row, 0).toString();
        String tipoMant = this.infoMant_Table.getModel().getValueAt(row, 1).toString();
        String ciEmpleado = this.infoMant_Table.getModel().getValueAt(row, 2).toString();
        Integer horasT =  Integer.parseInt(this.infoMant_Table.getModel().getValueAt(row, 3).toString());
        Integer nroKiosco = Integer.parseInt(infoBox.getSelectedItem().toString().substring(0, infoBox.getSelectedItem().toString().indexOf(" ")));
        
        try {
            Integer nroTipoMant = OracleMethods.buscarNroTipoMantenimiento(tipoMant);
            if (nroTipoMant != 0)
                infoMant = OracleMethods.buscarCostosMant(tipoMant).split(";");    
        
            int resultado = EliminacionInformacion.eliminarMantenimiento(fechaMant, tipoMant, nroTipoMant, ciEmpleado, horasT, nroKiosco);
            if (resultado != 0){
                JOptionPane.showMessageDialog(this, "Eliminacion Exitosa");
                this.mostrarInfoMantenimiento(infoBox.getSelectedItem().toString().substring(0, infoBox.getSelectedItem().toString().indexOf(" ")));
                this.infoMant_Text.setText("");
            }
            
        } catch (SQLException ex) {
            System.out.println(ex);
        }   
        
    }
    
    limpiarCamposInfoMantenimiento();
    this.editarMantButton.setEnabled(true);
}//GEN-LAST:event_eliminarMantButtonActionPerformed

private void registrarPedidoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registrarPedidoButtonActionPerformed
    if (this.jLabel1.getText().equals("Cliente:")){
        if(registrarPedidoButton.getText().equals("Registrar")){
            this.manejoMantenimiento_Pane.setEnabledAt(1, true);
            this.manejoMantenimiento_Pane.setSelectedIndex(1);
            this.eliminarPedidoButton.setEnabled(false);
            this.editarPedidoButton.setEnabled(false);
            this.manejoMantenimiento_Pane.setTitleAt(1, "Creacion pedido");
            limpiarCamposCreacionPedido();
            this.registrarPedidoButton.setText("Confirmar");
            this.editarPedidoButton.setText("Editar");
            
        }
        else{
            
            if (materialBox.getSelectedItem().equals("Elegir material") || tamanoBox.getSelectedItem().equals("Elegir tamaño")   
                    || clientesBox.getSelectedItem().equals("RIF - Cliente") || fechaCchooser.getDate() == null 
                    || fechaEchooser.getDate() == null)
                
                    JOptionPane.showMessageDialog(this, "Error, campos incompletos o erroneos");
            
            else{ 
                try {
                        Integer nroMaterial = Integer.parseInt(materialBox.getSelectedItem().toString().substring(0, materialBox.getSelectedItem().toString().indexOf(".")));
                        Integer nroTamano = Integer.parseInt(tamanoBox.getSelectedItem().toString().substring(0, tamanoBox.getSelectedItem().toString().indexOf(".")));
                        Integer cantidad = Integer.parseInt(cantidadBox.getSelectedItem().toString());
                        String fechaCreacion = fecha.format(fechaCchooser.getDate());
                        String fechaEntrega = fecha.format(fechaEchooser.getDate());
                        String rifCliente = clientesBox.getSelectedItem().toString().substring(0, clientesBox.getSelectedItem().toString().indexOf(" "));
                        Integer costoPedido = Integer.parseInt(costoField.getText());               

                        int pedido_PK_Creado = CreacionInformacion.crearPedido(nroMaterial, nroTamano, cantidad, fechaCreacion, fechaEntrega, rifCliente, costoPedido);
                        if (pedido_PK_Creado != 0){
                            
                            Pedido pedido = new Pedido(pedido_PK_Creado, nroMaterial, nroTamano, cantidad, fechaCreacion, fechaEntrega, rifCliente, costoPedido);
                            arrayPedidos.add(pedido); 
                            
                            JOptionPane.showMessageDialog(this, "Registro Exitoso");
                            limpiarCamposCreacionPedido();
                            montoTotalPedidos = montoTotalPedidos + costoPedido;
                        
                        }
                        else
                            JOptionPane.showMessageDialog(this, "No se pudo realizar el registro");
                        
                        int confirmacion = JOptionPane.showConfirmDialog(this, "¿Desea crear otro pedido para este mismo cliente?"); 
                    
                    if (confirmacion != 0){
                        CreacionInformacion.crearFacturacionPedido(arrayPedidos, montoTotalPedidos);
                        limpiarCamposCreacionPedido();
                        limpiarCamposInfoPedido();
                        this.manejoMantenimiento_Pane.setSelectedIndex(0);
                        this.mostrarInfoPedido(infoBox.getSelectedItem().toString().substring(0, infoBox.getSelectedItem().toString().indexOf(" ")));
                        this.manejoMantenimiento_Pane.setEnabledAt(1, false);
                        this.manejoMantenimiento_Pane.setTitleAt(1, "");   
                        this.clientesBox.setSelectedItem(0);
                    }
                    else
                        this.clientesBox.setEnabled(false);

                } catch (SQLException ex) {
                    System.out.println(ex);
                }
            }
        }
    }
}//GEN-LAST:event_registrarPedidoButtonActionPerformed

private void eliminarPedidoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliminarPedidoButtonActionPerformed
    this.registrarPedidoButton.setEnabled(false);
    this.editarPedidoButton.setEnabled(false);
    
    int confirmacion = JOptionPane.showConfirmDialog(this, "¿Desea eliminar ésta informacion de pedido?");

    if(confirmacion == 0){
        int row = this.infoPedido_Table.getSelectedRow();
        
        Integer nroPedido = Integer.parseInt(infoPedido_Table.getModel().getValueAt(row, 0).toString());
        Integer cantidad = Integer.parseInt(infoPedido_Table.getModel().getValueAt(row, 1).toString());
        String material = infoPedido_Table.getModel().getValueAt(row, 2).toString();
        String fechaCreacion =  infoPedido_Table.getModel().getValueAt(row, 3).toString();
        String fechaEntrega = infoPedido_Table.getModel().getValueAt(row, 4).toString();
        String rifCliente = infoBox.getSelectedItem().toString().substring(0, infoBox.getSelectedItem().toString().indexOf(" "));
        
        try {  
            int resultado = EliminacionInformacion.eliminarPedido(nroPedido, cantidad, material, fechaCreacion, fechaEntrega, rifCliente);
            if (resultado != 0){
                JOptionPane.showMessageDialog(this, "Eliminacion Exitosa");
                this.mostrarInfoPedido(infoBox.getSelectedItem().toString().substring(0, infoBox.getSelectedItem().toString().indexOf(" ")));
                this.infoPedido_Text.setText("");
            }
            else{
                JOptionPane.showMessageDialog(this, "No se pudo realizar la operacion");
                this.registrarPedidoButton.setEnabled(true);
                this.editarPedidoButton.setEnabled(true);
            }
            
        } catch (SQLException ex) {
            System.out.println(ex);
            Logger.getLogger(ManejoMantenimientoGUI.class.getName()).log(Level.SEVERE, null, ex);
        }   
        
    }
    
    limpiarCamposInfoMantenimiento();
    this.editarMantButton.setEnabled(true);
}//GEN-LAST:event_eliminarPedidoButtonActionPerformed

private void editarPedidoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarPedidoButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_editarPedidoButtonActionPerformed

private void fechaMantChooserPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_fechaMantChooserPropertyChange
    if((tiposMantBox.getSelectedItem() != null) && (empleadosCIBox.getSelectedItem() != null) 
            && (kioscosBox.getSelectedItem() != null)  && (fechaMantChooser.getDate() != null)){
        
        validarKioscosEnMantenimiento(); 
        validarEmpleadosDisponibles();

        if(kioscosBox.getItemCount() == 1)
            this.jLabel23.setVisible(true);
        else
            this.jLabel23.setVisible(false);

        if((empleadosCIBox.getItemCount() == 1))
            this.jLabel22.setVisible(true);
        else
            this.jLabel22.setVisible(false);
        
            
    }
}//GEN-LAST:event_fechaMantChooserPropertyChange

private void empleadosCIBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_empleadosCIBoxActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_empleadosCIBoxActionPerformed

private void fechaCchooserPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_fechaCchooserPropertyChange
    if((materialBox.getSelectedItem() != null) && (tamanoBox.getSelectedItem() != null) 
            && (clientesBox.getSelectedItem() != null)){
        
        if (fechaCchooser.getDate() != null){
            this.fechaEchooser.setEnabled(true);
            Calendar fechaCreacion = fechaCchooser.getCalendar();
            fechaCreacion.add(Calendar.DATE, 7);
            this.fechaEchooser.setMinSelectableDate(fechaCreacion.getTime());
        }
        else
            this.fechaEchooser.setEnabled(false);
    }
}//GEN-LAST:event_fechaCchooserPropertyChange

    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton backButton;
    private javax.swing.JComboBox cantidadBox;
    private javax.swing.JComboBox clientesBox;
    private javax.swing.JTextField costoField;
    private javax.swing.JTextField costoHoraClienteText;
    private javax.swing.JTextField costoHoraEmpText;
    private javax.swing.JPanel creacionMant_Panel;
    private javax.swing.JPanel creacionPedido_Panel;
    private javax.swing.JButton editarMantButton;
    private javax.swing.JButton editarPedidoButton;
    private javax.swing.JButton eliminarMantButton;
    private javax.swing.JButton eliminarPedidoButton;
    private javax.swing.JComboBox empleadosCIBox;
    private com.toedter.calendar.JDateChooser fechaCchooser;
    private com.toedter.calendar.JDateChooser fechaEchooser;
    private com.toedter.calendar.JDateChooser fechaMantChooser;
    private javax.swing.JSpinner horasSpinner;
    private javax.swing.JComboBox infoBox;
    private javax.swing.JPanel infoMant_Panel;
    private javax.swing.JTable infoMant_Table;
    private javax.swing.JTextArea infoMant_Text;
    private javax.swing.JPanel infoPedido_Panel;
    private javax.swing.JTable infoPedido_Table;
    private javax.swing.JTextArea infoPedido_Text;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JComboBox kioscosBox;
    private javax.swing.JTabbedPane manejoMantenimiento_Pane;
    private javax.swing.JComboBox materialBox;
    private javax.swing.JTextField montoTotalField;
    private javax.swing.JPanel panelManejoMantenimiento;
    private javax.swing.JPanel panelManejoPedido;
    private javax.swing.JButton registrarMantButton;
    private javax.swing.JButton registrarPedidoButton;
    private javax.swing.JComboBox tamanoBox;
    private javax.swing.JComboBox tiposMantBox;
    // End of variables declaration//GEN-END:variables
}
